# Maintainer: Bruno Pagani <archange@archlinux.org>

_pkg=pyxDamerauLevenshtein
pkgname=python-${_pkg,,}
pkgver=1.7.1
pkgrel=2
pkgdesc="Implements the Damerau-Levenshtein (DL) edit distance algorithm"
arch=(loong64 x86_64)
url="https://github.com/gfairchild/pyxDamerauLevenshtein"
license=(BSD)
depends=(python)
makedepends=(python-setuptools cython)
checkdepends=(python-pytest)
# No tests in PyPi tarballs
#source=(https://files.pythonhosted.org/packages/source/${_pkg::1}/${_pkg}/${_pkg}-${pkgver}.tar.gz)
source=(${url}/archive/v${pkgver}/${_pkg}-${pkgver}.tar.gz)
sha256sums=('e2bd561d97dc5441772379826d665fa8b2bffc2e0180da03b2b29b48f38b97d5')

build() {
  cd ${_pkg}-${pkgver}
  python setup.py build
}

check() {
  cd ${_pkg}-${pkgver}
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  PYTHONPATH="${PWD}"/build/lib.linux-${CARCH}-cpython-${python_version/./} pytest
}

package() {
  cd ${_pkg}-${pkgver}
  python setup.py install --prefix=/usr --root="${pkgdir}" --skip-build --optimize=1
  install -Dm644 LICENSE -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
